-
Notifications
You must be signed in to change notification settings - Fork 2
Return archive in zip stream #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: yichen88 <[email protected]>
f598c6a to
7169c9b
Compare
|
SonarCloud Quality Gate failed.
|
mathbagu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my point of view, you miss something. When I created the issue, I would to create a ZipInputStream to avoid creating a temporary folder on the server side. I don't understand how this PR how solve this issue?
| try { | ||
| if (Files.isDirectory(someFileToZip)) { | ||
| addDirectory(zos, pathInZip); | ||
| } else { | ||
| addFile(zos, someFileToZip, pathInZip); | ||
| } | ||
| } catch (IOException e) { | ||
| throw new AfsStorageException(e.getMessage()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make this lambda smaller, you should catch exception in addDirectory and addFile
| public static ZipInputStream zip(Path dir, boolean deleteDirectory) throws IOException { | ||
| byte[] bytes; | ||
| try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
| ZipOutputStream zos = new ZipOutputStream(baos); | ||
| Stream<Path> walk = Files.walk(dir)) { | ||
| zip(walk, dir, zos); | ||
| zos.close(); | ||
| baos.close(); | ||
| bytes = baos.toByteArray(); | ||
| } catch (IOException | AfsStorageException e) { | ||
| throw new IOException(e); | ||
| } | ||
|
|
||
| if (deleteDirectory) { | ||
| deleteDirectory(dir); | ||
| } | ||
| return new ZipInputStream(new ByteArrayInputStream(bytes)); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you creating a pipe (i.e. creating a zip from a path, and returning a input-stream for this path)?
In that case, could you use PipedInputStream/PipedOutputStream as it's done in NetworkXml.copy?
Adding and/or expanding the json model generation of cells, blocks, nodes, edges, graph, substationgraph classes Generating and comparing json instead of svg files for some test cases Adding test for SVGWriter based on graph manually created Corrections in test case for Sonar (at least one assertion in test method) We don't rely on filesystem anymore in test cases Signed-off-by: Franck LECUYER <[email protected]>
Please check if the PR fulfills these requirements (please use
'[x]'to check the checkboxes, or submit the PR and then click the checkboxes)Does this PR already have an issue describing the problem ? If so, link to this issue using
'#XXX'and skip the rest#31
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
Does this PR introduce a breaking change or deprecate an API? If yes, check the following:
Other information:
(if any of the questions/checkboxes don't apply, please delete them entirely)